<template>
	<view class="content">
		
		<!-- http://localhost:8080/?code=041z6b1w3w943Y2biy2w32IQj71z6b13&state=STATE#/pages/login/login -->
		
		<view class="iboxs">
			<image :src="about" mode=""></image>
			
			<view style="height: 100rpx;"></view>
			
			<view class="iboxs-login" @tap="submit()">
				立即登陆
			</view>
		</view>
	</view>
</template>

<script>
	
	import {curl} from 'common/api.js';
		
	export default {
		data() {
			return {
				code:'code',
				about:'/static/logo.png',
				avatar:''
			}
		},
		
		onLoad(){
			
			console.log('---------')
		
			curl('index/setting',{}).then((res)=>{
				console.log(res.data)
				this.appid=res.data.appid;
			
			});
			
			var code = this.getUrlCode().code; // 截取code
		},
			
		onShow() {
			
			var user=uni.getStorageSync('user');
			if	(user.id){
				uni.switchTab({
					url:"/pages/member/member"
				})
				return false;
			}
			
		},
			
		methods: {
			back(){
				
				location.href="/h5";
				// uni.switchTab({
				// 	url:"/pages/index/index"
				// })
			},
			submit(){
				// #ifdef H5
				let appid =this.appid;
				
				let url="http://gzh.stp1.cn/h5/#/pages/login/loginb";
				url=encodeURIComponent(url);
				console.log(url);
				
		
	
				var wxUrl ='https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appid+
				'&redirect_uri=' +url +'&response_type=code' +
				'&scope=snsapi_userinfo' +'&state=STATE#wechat_redirect';
				
				console.log(wxUrl);
				window.location.href = wxUrl;
				// #endif
			},
			
			
			getUrlCode() {
				// 截取url中的code方法
				var url = location.href; //获取打开的公众号的路径
				let winUrl = url;
				var theRequest = new Object();
				if (url.indexOf('?') != -1) {
					var str = url.substr(url.indexOf('?') + 1);
					var strs = str.split('&');
					for (var i = 0; i < strs.length; i++) {
						var items = strs[i].split('=');
						theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
					}
				}
				return theRequest;
			}
		}
	}
</script>

<style>
	.iboxs image{
		width: 180rpx;height: 180rpx;margin: auto;display: block;
	}
	.iboxs-title{
		width: 100%;height: 100rpx;line-height: 100rpx;text-align: center;font-size: 32rpx;font-weight: bold;
	}
	
	.iboxs-login{
		width: 500rpx;height: 90rpx;margin:10px auto;background: #14CB2E;color: #FFFFFF;text-align: center;
		line-height: 90rpx;border-radius: 90rpx;
	}
	.iboxs-back{
		width: 500rpx;height: 90rpx;margin:20px auto;color: #949494;text-align: center;
		line-height: 90rpx;border-radius: 90rpx;border: 1px solid #ececec;
	}
.iboxs{
	width: 600rpx;height: 700rpx;border: 1px solid #FFFFFF;
	position: fixed;left: 0;top: 0;right: 0;bottom: 0;margin: auto;
}
.content{
	
}
</style>